<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Index extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->model(array(
            'generic_model'
        ));
    }
    
    public function index() {
        $title['title'] = 'Inicio';
        
        //$data['random'] = $this->generic_model->get_random();
        $data['random'] = $this->generic_model->get_adjuntos_ordenados();
        foreach($data['random'] as $key => $value) {
            $data['random'][$key]['adjuntos'] = $this->generic_model->get_adjuntos($value['idunidad']);
            $data['random'][$key]['unidad'] = $this->generic_model->get('unidades', $value['idunidad']);
        }
        
        $this->load->view('layout/header', $title);
        $this->load->view('index/index', $data);
        $this->load->view('layout/footer');
    }
}
?>
